Class Communities
java.lang.Object
edu.claflin.finder.algo.clustering.Communities
- Author:
- Cesar Martin
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionCommunities(Graph g, boolean weighted) Constructor to initialize 1-Node Communities from a Graph.Constructor to create Communities from existing Community group.privateConstructor called by copy(). -
Method Summary
Modifier and TypeMethodDescriptiondoubleFraction of edges incident to Nodes in the given Community.booleanconnectedCommunities(List<Node> c1, List<Node> c2) Determine whether 2 Communities are connected.booleancontainsKey(Integer key) Whether the Community structure contains the given community index.copy()doubleFraction of edges that join vertices in 2 given Communities.Get Community.getList()Get Community structure as a List of Node Lists.doublegetM2()intindexOfNode(Node n) Get the index of the Community the given Node is in.booleankeys()Get Community indices.voidmergeCommunities(int j, int i) Merge community j and i into jdoubleThe Community Structure Quality Measure used by the algorithms.intNodesInSameCommunity(Node n1, Node n2) Determine if 2 Nodes are in the same Community.intsize()toString()
-
Field Details
-
list
Map of Community Number to Nodes of the Community. Some algorithms may rely on these numbers staying in the same order. -
g
-
weighted
private boolean weighted -
m2
private double m2
-
-
Constructor Details
-
Communities
Constructor to initialize 1-Node Communities from a Graph.- Parameters:
g- the graphweighted- finding weighted communities?
-
Communities
Constructor to create Communities from existing Community group.- Parameters:
list- the existing Communitiesg- the graphweighted- finding weighted communities?
-
Communities
Constructor called by copy(). Copies values without looping because the looping was done in copy().- Parameters:
list- the Communitiesg- the Graphweighted- finding weighted Communities?m2- the m2
-
-
Method Details
-
copy
-
size
public int size() -
isWeighted
public boolean isWeighted() -
getM2
public double getM2() -
get
Get Community.- Parameters:
key- the index of the Community- Returns:
- the Community
-
keys
Get Community indices.- Returns:
- the Community indices
-
containsKey
Whether the Community structure contains the given community index.- Parameters:
key- the community index- Returns:
- true if the Community structure contains the index, false otherwise
-
getList
Get Community structure as a List of Node Lists.- Returns:
- the Communities as lists.
-
indexOfNode
Get the index of the Community the given Node is in.- Parameters:
n- the node- Returns:
- the index of the Community the given Node is in.
-
NodesInSameCommunity
Determine if 2 Nodes are in the same Community.- Parameters:
n1- NodeStats 1n2- NodeStats 2- Returns:
- 1 if Nodes in same Community, 0 otherwise
-
connectedCommunities
Determine whether 2 Communities are connected.- Parameters:
c1- Community 1c2- Community 2- Returns:
- true if Communities are connected, false otherwise
-
a
Fraction of edges incident to Nodes in the given Community.- Parameters:
c- the Community- Returns:
- the fraction of edges incident to Nodes in the Community
-
e
Fraction of edges that join vertices in 2 given Communities.- Parameters:
c1- Community 1c2- Community 2- Returns:
- the fraction of edges that join vertices in the 2 Communities
-
modularity
public double modularity()The Community Structure Quality Measure used by the algorithms. It is the sum of the fractions of the deviation edges that join vertices between each Community to itself from the expected fraction in a random network.- Returns:
- the modularity
-
mergeCommunities
public void mergeCommunities(int j, int i) Merge community j and i into j- Parameters:
j- the community to store the resulti- the community the offers its Nodes
-
toString
-